import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class Sy2_1 {
    private static String driver="com.mysql.jdbc.Driver";
    private static String url="jdbc:mysql://localhost:3306/school?useSSL=false";
    private static String user="root";
    private static String password="123456";

    public static void main(String[] args) {
        Connection conn =null;

        try {
            Class.forName(driver);
            System.out.println("加载驱动器成功");
            conn = DriverManager.getConnection(url,user,password);
            System.out.println("连接成功");
        } catch (ClassNotFoundException e) {
            System.out.println("加载驱动器失败！");
            throw new RuntimeException(e);
        } catch (SQLException e) {
            System.out.println("连接失败，请确定连接参数是否正确！");
            throw new RuntimeException(e);
        }
        try {
            conn.close();
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
        System.out.println("已处理完毕，关闭了和数据库的连接");
    }
}
